﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Communication;

namespace Test
{
    class Program
    {
        static IHSSerialPort port = null;
        static void Main(string[] args)
        {

            port = new HSSerialPort(Encoding.ASCII, 68, "COM3", 9600);
            port.OnReceivedCompleted += new ReceiveCompleted(port_OnReceivedCompleted);

            try
            {
                port.Open();
                while (true)
                {
                    byte[] cammand = new byte[] { 83, 84, 65, 0XAB, 0XCD, 0X81, 0X01, 0X23, 69, 78, 68 };


                    port.Send(cammand);
                    Console.ReadKey();
                }
            }
            catch
            {
                port.Close();
                Console.ReadKey();
            }

        }

        static void port_OnReceivedCompleted(List<int> result)
        {
            try
            {
                Console.WriteLine(result.Count);
                //string rlt = port.Default.GetString(result.ToArray());
            }
            catch
            {
            }
        }

        static void port_OnReceivedCompleted(List<byte> result)
        {

        }
    }
}
